Skip to content

feat(client): add AI detection cache and audit log methods - #61

Open
beneboy wants to merge 2 commits into
mainfrom
no-ticket-ai-span-cache
Open

beneboy wants to merge 2 commits into
mainfrom
no-ticket-ai-span-cache

Conversation

@beneboy

@beneboy beneboy commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator
  • Add get_ai_detection_cache_size_bytes, which returns the size of the AI detection cache in bytes.
  • Add clear_ai_detection_cache(unused_for_days=None), which deletes every cache entry, or only the entries no masking run has used in unused_for_days days. It returns an AiDetectionCacheClearResult with the bytes freed and the size after the clear.
  • Add list_audit_logs(limit=None) and iter_audit_logs, which return audit log entries newest first as AuditLog models. The new AuditLogAction enum types action. project and project_name are None on servers older than 3.26.20.
  • Bump the version to 1.6.0. The cache methods need server version 3.26.20, which adds the /api/ai-detection-cache/ endpoints.

ui-testing uses raw make_request calls for the cache size and the audit log today (datamasque/ui-testing!293). After 1.6.0 is released, ui-testing moves to these methods.

Add get_ai_detection_cache_size_bytes and clear_ai_detection_cache (returning AiDetectionCacheClearResult) to SettingsClient, and an AuditLogClient with iter_audit_logs and list_audit_logs returning AuditLog models newest first. Bump the version to 1.6.0.
Comment thread pyproject.toml
[project]
name = "datamasque-python"
version = "1.5.0"
version = "1.6.0"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.6.0 already went out with the projects epic, can this rebase onto main, drop the version bump and add its notes to the unreleased section in HISTORY.rst?

category: str
"""The area the event belongs to, such as `auth`, `run` or `settings`, or the kind of object it changed."""

action: AuditLogAction

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should an unknown action fail the whole listing? Same problem #86 just fixed for resource types

class AuditLogClient(BaseClient):
"""Audit log API methods. Mixed into `DataMasqueClient`."""

def iter_audit_logs(self) -> Iterator[AuditLog]:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth taking a project filter? The audit log endpoint has accepted ?project= since 3.26.22

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants